package org.znxs.znxsojjudge.codeSandbox.impl;

import lombok.extern.slf4j.Slf4j;
import org.znxs.model.model.enums.JudgeInfoMessageEnum;
import org.znxs.model.model.enums.QuestionSubmitStatusEnum;
import org.znxs.model.model.judge.ExecuteCodeRequest;
import org.znxs.model.model.judge.ExecuteCodeResponse;
import org.znxs.model.model.judge.JudgeInfo;
import org.znxs.znxsojjudge.codeSandbox.CodeSandbox;

import java.util.List;

/**
 * 实例代码沙箱（演示）
 */
@Slf4j
public class ExampleCodeSandbox implements CodeSandbox {
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        // 执行代码
        List<String> inputList = executeCodeRequest.getInputList();
        // todo 执行代码

        // 返回对象
        ExecuteCodeResponse executeCodeResponse = new ExecuteCodeResponse();
        executeCodeResponse.setOutputList(inputList);
        executeCodeResponse.setMessage("执行成功");
        executeCodeResponse.setStatus(QuestionSubmitStatusEnum.SUCCESS.getValue());
        JudgeInfo judgeInfo = new JudgeInfo();
        judgeInfo.setMessage(JudgeInfoMessageEnum.ACCEPTED.getText());
        judgeInfo.setMemoryLimit(100L);
        judgeInfo.setTime(100L);
        executeCodeResponse.setJudgeInfo(judgeInfo);
        return executeCodeResponse;
    }
}
